﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdSelectionSet : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdSelectionSet(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdSelectionSet_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdSelectionSet obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdSelectionSet()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdSelectionSet(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdSelectionSet cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdSelectionSet_cast(OdRxObject.getCPtr(pObj));
			OdSelectionSet result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdSelectionSet_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdSelectionSet_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdSelectionSet_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdSelectionSet createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdSelectionSet_createObject();
			OdSelectionSet result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdSelectionSet)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdRxObject baseDatabase()
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdSelectionSet_baseDatabase(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdSelectionSetIterator newIterator()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdSelectionSet_newIterator(this.swigCPtr);
			OdSelectionSetIterator result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdSelectionSetIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdSelectionSetIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdSelectionSetIterator)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual uint numEntities()
		{
			uint result = GlobalsPINVOKE.OdSelectionSet_numEntities(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void append(OdDbStub entityId, OdDbSelectionMethod pMethod)
		{
			GlobalsPINVOKE.OdSelectionSet_append__SWIG_0(this.swigCPtr, OdDbStub.getCPtr(entityId), OdDbSelectionMethod.getCPtr(pMethod));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void append(OdDbStub entityId)
		{
			GlobalsPINVOKE.OdSelectionSet_append__SWIG_1(this.swigCPtr, OdDbStub.getCPtr(entityId));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void append(OdDbBaseFullSubentPath subent, OdDbSelectionMethod pMethod)
		{
			GlobalsPINVOKE.OdSelectionSet_append__SWIG_2(this.swigCPtr, OdDbBaseFullSubentPath.getCPtr(subent), OdDbSelectionMethod.getCPtr(pMethod));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void append(OdDbBaseFullSubentPath subent)
		{
			GlobalsPINVOKE.OdSelectionSet_append__SWIG_3(this.swigCPtr, OdDbBaseFullSubentPath.getCPtr(subent));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void append(OdSelectionSet pSSet)
		{
			GlobalsPINVOKE.OdSelectionSet_append__SWIG_4(this.swigCPtr, OdSelectionSet.getCPtr(pSSet));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void remove(OdDbStub entityId)
		{
			GlobalsPINVOKE.OdSelectionSet_remove__SWIG_0(this.swigCPtr, OdDbStub.getCPtr(entityId));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void remove(OdDbBaseFullSubentPath subent)
		{
			GlobalsPINVOKE.OdSelectionSet_remove__SWIG_1(this.swigCPtr, OdDbBaseFullSubentPath.getCPtr(subent));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void remove(OdSelectionSet pSSet)
		{
			GlobalsPINVOKE.OdSelectionSet_remove__SWIG_2(this.swigCPtr, OdSelectionSet.getCPtr(pSSet));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool isMember(OdDbStub entityId)
		{
			bool result = GlobalsPINVOKE.OdSelectionSet_isMember__SWIG_0(this.swigCPtr, OdDbStub.getCPtr(entityId));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool isMember(OdDbBaseFullSubentPath subent)
		{
			bool result = GlobalsPINVOKE.OdSelectionSet_isMember__SWIG_1(this.swigCPtr, OdDbBaseFullSubentPath.getCPtr(subent));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbSelectionMethod method(OdDbStub entityId)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdSelectionSet_method(this.swigCPtr, OdDbStub.getCPtr(entityId));
			OdDbSelectionMethod result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbSelectionMethod)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbSelectionMethod)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbSelectionMethod)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void clear()
		{
			GlobalsPINVOKE.OdSelectionSet_clear(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
